{include file="public/head"/}
<style>
  .row .cf {
    margin-bottom: 10px;
  }
</style>

<div class="main-container" id="main-container">
  <script type="text/javascript">
    try {
      ace.settings.check('main-container', 'fixed')
    } catch (e) {
    }
  </script>

  <div class="main-container-inner">
    <a class="menu-toggler" id="menu-toggler" href="#">
      <span class="menu-text"></span>
    </a>

    {include file="public/nav"/}

    {include file="public/menu"/}

    <div class="main-content">
      {include file="public/breadcrumb"/}

      <div class="page-content">
        <div class="row">
          <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <form class="form-horizontal" id="fmUser" method="post">
              <input type="hidden" name="id" value="{$user.id}">
              <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right"> 姓名 </label>
                <div class="col-sm-9">
                  <input type="text" name="name" placeholder="姓名" class="col-xs-10 col-sm-5" value="{$user.name}">
                  <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right"> 登陆名 </label>
                <div class="col-sm-9">
                  <input type="text" name="lname" placeholder="登陆名" class="col-xs-10 col-sm-5" value="{$user.lname}">
                  <!--<span class="help-inline col-xs-12 col-sm-7">
                      <span class="middle">注意需符合PHP变量名条件，前台调用：<literal></literal></span>
                  </span>-->
                </div>
              </div>
              <div class="space-4"></div>
              <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right"> 密码 </label>
                <div class="col-sm-9">
                  <input type="password" name="pwd" placeholder="密码" class="col-xs-10 col-sm-5" value="{$user.pwd}">
                  <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right"> 确认密码 </label>
                <div class="col-sm-9">
                  <input type="password" name="repwd" placeholder="确认密码" class="col-xs-10 col-sm-5" value="{$user.pwd}">
                  <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                </div>
              </div>
              <!--<div class="form-group">-->
                <!--<label class="col-sm-1 control-label no-padding-right"> 联系方式 </label>-->
                <!--<div class="col-sm-9">-->
                  <!--<input type="text" name="contact" placeholder="联系方式" class="col-xs-10 col-sm-5"-->
                         <!--value="{$user.contact}">-->
                  <!--<span class="help-inline col-xs-12 col-sm-7">-->
                    <!--<span class="middle"></span>-->
                  <!--</span>-->
                <!--</div>-->
              <!--</div>-->
              <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right"> 角色 </label>
                <div class="col-sm-9">
                  <!--<div class="col-xs-10 col-sm-5">-->
                    <select name="roles" class="col-xs-10 col-sm-5">
                      {volist name="$roles" id="r"}
                      <option value="{$r.id}" {if ($user.roles==$r.id)} selected {/if}>{$r.name}</option>
                      {/volist}
                      <!--<option value="1">店长</option>-->
                      <!--<option value="2">维修部</option>-->
                      <!--<option value="4">接待部</option>-->
                      <!--<option value="8">维修技师</option>-->
                      <!--<option value="16">接待员</option>-->
                    </select>
                  <!--</div>-->
                  <span class="help-inline col-xs-12 col-sm-7">
                          <span class="middle"></span>
                      </span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right"> 所属门店 </label>
                <div class="col-sm-9">
                  <select name="branch_id" class="col-xs-10 col-sm-5">
                    {volist name="$branch" id="b"}
                    <option value="{$b.id}"  {if ($user.branch_id==$b.id)} selected {/if}>{$b.num}</option>
                    {/volist}
                  </select>
                  <!--</div>-->
                  <span class="help-inline col-xs-12 col-sm-7">
                          <span class="middle"></span>
                      </span>
                </div>
              </div>
              <input name="enable" type="hidden" value="1" }>
              <!--<div class="form-group">-->
                <!--<label class="col-sm-1 control-label no-padding-right"> 是否启用 </label>-->
                <!--<div class="col-sm-9 col-xs-3">-->
                  <!--<label>-->
                    <!--<input name="enable" class="ace ace-switch" type="checkbox" {$user.enable ? 'checked' : ''}>-->
                    <!--<span class="lbl"></span>-->
                  <!--</label>-->
                <!--</div>-->
              <!--</div>-->
              <hr>
              <div class="col-md-offset-2 col-md-9">
                <a class="btn btn-info submit">
                  <i class="icon-ok bigger-110"></i>
                  提交
                </a>
                <button class="btn" type="reset">
                  <i class="icon-undo bigger-110"></i>
                  重置
                </button>
              </div>
            </form>
            <!-- PAGE CONTENT ENDS -->
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.page-content -->
    </div><!-- /.main-content -->

  </div><!-- /.main-container-inner -->

  <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
  </a>
</div>
<!-- /.main-container -->
{include file="public/footerjs"/}

<script>
  $(function () {
    var $fmUser = $('#fmUser');
    $fmUser.find('a.submit').click(function () {
      var param = ittaoli.serializeObject($fmUser);
      if (param.pwd != param.repwd) {
        bootbox.alert('两次密码不一致~');
        return;
      }
      param.id = param.id == '' ? 0 : param.id;
      param.enable = param.enable == 'on' ? 1 : 0;
      console.log(param);
      $.post("{:Url('doAdd')}", {param: JSON.stringify(param)}, function (data) {
        if (data > 0) {
          bootbox.alert("保存成功！");
          setTimeout(function () {
            location.href = "{:url('index')}";
          }, 1000);
        } else {
          bootbox.alert("保存失败！");
        }
      });
    });
  });
</script>


{include file="public/foot"/}
